package cn.zymx.webTM.web.controller;

import cn.zymx.webTM.web.dao.entity.Chatroom;
import cn.zymx.webTM.web.dao.mapper.ChatroomMapper;
import cn.zymx.webTM.web.services.ITestService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/room")
public class RoomController {
	@Autowired
	private ChatroomMapper chatroomMapper;

	@RequestMapping(value = "/getRoomList", produces = "application/json;charset=utf-8")
	@ResponseBody
	public String getRoomList(HttpSession session) {
		List<Chatroom> chatrooms = chatroomMapper.selectByExample(null);
		String s = JSONObject.toJSONString(chatrooms);
		return  s;
	}
}
